<?php

namespace Core;

/**
 *
 */
class Func
{

	/**
	 * 设置子进程的名称
	 * @param type $title
	 */
	public static function setProcessTitle($title)
	{
		Log::write("setProcessTitle : $title");

		if (function_exists('cli_set_process_title')) {
			cli_set_process_title($title);
		} elseif (extension_loaded('proctitle') && function_exists('setproctitle')) {
			setproctitle($title);
		}
	}

	/**
	 * 居中打印字符串
	 * @param type $lines
	 */
	public static function CenterLine(&$lines)
	{
		return $lines;
	}

	/**
	 * 输出彩色文字
	 * @param type $text
	 * @param type $err
	 */
	public static function echoColorText($text = '', $err = false)
	{
		if (!$err)
			fwrite(STDOUT, "\033[0;32;1m$text \033[0m\n");
		else
			fwrite(STDOUT, "\033[0;31;1m$text \033[0m\n");
	}

}
